package lt.liepasoft.locr;

import java.util.List;

import lt.liepasoft.locr.data.Bounds;
import lt.liepasoft.locr.data.OcrImage;
import lt.liepasoft.locr.data.RgbImage;
import lt.liepasoft.locr.data.Symbol;

/**
 * Abstract 
 * 
 * @author Tautvydas Liepa
 *
 */

public abstract class Ocr {
    public String doOCR(RgbImage image, Bounds b){        
        return recognizeSymbols(findSymbols(processImage(image, b), b));
    }           
    
    public String doOCR(RgbImage image, Scanner scanner, Bounds b){
        return recognizeSymbols(scanner.scan(processImage(image, b), b));
    }    
    
    public String doOCR(OcrImage image, Scanner scanner, Bounds b){
        return recognizeSymbols(scanner.scan(image, b));
    }    

    /**
     * 
     * @param image
     * @param bounds
     * @return
     */
    abstract protected OcrImage processImage(RgbImage image, Bounds bounds);
    
    /**
     * 
     * @param image
     * @param bounds
     * @return
     */
    abstract protected List <Symbol> findSymbols(OcrImage image, Bounds bounds);
    
    /**
     * 
     * @param symbols
     * @return
     */
    abstract protected String recognizeSymbols(List <Symbol> symbols);
}
